import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/Home/index.vue'
import dashboardView from '../views/Dashboard/index.vue'
import Layout from '../components/Layout/index.vue'


export const routes = [

  { /* 404 页面 */
    path: '/404',
    component: () => import('@/views/404.vue'),
    hidden: true
  },

  {/* 仪表盘 */
    path: '/',
    component: Layout,
    children: [{
      path: '/dashboard',
      name: 'Dashboard',
      component: dashboardView,
      meta: {
        title: '仪表盘',
        type: [1]
      }
    },
    { /* 首页 */
      path: '/home',
      name: 'Home',
      component: HomeView,
      meta: {
        title: '首页',
        type: [0]
      }
    }]
  },

  { /* 试卷专区 */
    path: '/test-paper',
    redirect: '/test-paper/paper-list',
    component: Layout,
    meta: { title: '试卷管理' },
    children: [{
      path: '/paper-list/paper-list',
      name: 'PaperList',
      component: () => import('@/views/TestList/index.vue'),
      meta: {
        title: '试卷列表',
        type: [1]
      }
    }, {
      path: '/test-paper/create-paper',
      name: 'CreatePaper',
      component: () => import('@/views/createTest/index.vue'),
      meta: {
        title: '编纂试卷',
        type: [1]
      }
    }]
  },

  { /* 题库专区 */
    path: '/topic-manager',
    redirect: '/topic-manager/topic-list',
    component: Layout,
    meta: { title: '考题管理' },
    children: [{
      path: '/topic-manager/topic-list',
      name: 'TopicList',
      component: () => import('@/views/TopicList/index.vue'),
      meta: {
        title: '题库列表',
        type: [1]
      }
    }, {
      path: '/topic-manager/add-topic',
      name: 'AddTopic',
      component: () => import('@/views/AddTopic/index.vue'),
      meta: {
        title: '添加题目',
        type: [1]
      }
    }]
  },

  { /* 考试页面 */
    path: '/exam/:id',
    name: 'Exam',
    hidden: true,
    component: () => import('../views/Exam/index.vue')
  },

  {  /* 登录 */
    path: '/login',
    name: 'Login',
    hidden: true,
    component: () => import('../views/Login/index.vue')
  },

  { /* 未知页面做转发 */
    path: "/:pathMatch(.*)",
    redirect: "/404",
    name: "notMatch",
    hidden: true
  },

]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
  linkActiveClass: 'active' // 激活的添加 active 样式类
})

// export routes

export default router
